//
//  ViewController.m
//  CALayer-隐式动画
//
//  Created by hyl on 16/7/4.
//  Copyright © 2016年 hyl. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIView *redView;

@property (nonatomic,strong) CALayer *layer;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.layer=[CALayer layer];
    self.layer.frame=CGRectMake(150, 350, 80,80);
    self.layer.backgroundColor=[UIColor blueColor].CGColor;
    [self.view.layer addSublayer:self.layer];
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    //
    CGFloat angle=(arc4random_uniform(360)+1)/(M_PI*2);
    self.layer.transform=CATransform3DMakeRotation(angle, 0, 0, 1);
}
@end
